Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue: New Input System - All mouse buttons have the same pointer Id #2071

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

gapspt
Copy link

@gapspt gapspt commented Dec 3, 2024

Description

Fixes the following bug: https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-90349

When using the IPointerDownHandler (OnPointerDown method) with the New Input System, the eventData.pointerId for any mouse button is always the same, corresponding to the mouse's deviceId.

According to the documentation for Unity 2018:

When using a mouse the pointerId returns -1, -2, or -3. These are the left, right and center mouse buttons respectively.

I mention the 2018 because the documentation on the standalone Unity UI package is lacking the values for the mouse buttons.

Testing status & QA

Tested locally.

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

Note that m_CurrentPointerId is set and checked against the value -1, which is the same value that should be used for the left mouse button, but in the case of the m_CurrentPointerId it means "none". This is not a problem in the current fix, as it only changes the eventData object being passed to the event listeners, so the m_CurrentPointerId will still contain the original pointerId, which would be the mouse's deviceId .

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

… Id"

Fixes the following bug:

When using the IPointerDownHandler (OnPointerDown method) with the New Input System, the eventData.pointerId is always the same, corresponding to the deviceId.

According to the documentation [1] for Unity 2018: "When using a mouse the pointerId returns -1, -2, or -3. These are the left, right and center mouse buttons respectively."

I mention the 2018 because the documentation on the standalone Unity UI package [2] is lacking the values for the mouse buttons.

[1] https://docs.unity3d.com/2018.1/Documentation/ScriptReference/EventSystems.PointerEventData-pointerId.html
[2] https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.EventSystems.PointerEventData.html
@unity-cla-assistant
Copy link

unity-cla-assistant commented Dec 3, 2024

CLA assistant check
All committers have signed the CLA.

Restore the original pointerId, since the eventData is reused, to keep it correct at all times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants